<!DOCTYPE HTML>
<html>

<head>
    <title>Guacamole Tutorial</title>
</head>

<body>
<p>Hello World</p>


<!-- Guacamole -->
<script type="text/javascript"
        src="guacamole-common-js/all.min.js"></script>

<!-- Display -->
<div id="display"></div>

<!-- Init -->
<script type="text/javascript"> /* <![CDATA[ */

// Get display div from document
var display = document.getElementById("display");

// Instantiate client, using an HTTP tunnel for communications.
var guac = new Guacamole.Client(
    new Guacamole.HTTPTunnel("tunnel")
);

// Add client to display div
display.appendChild(guac.getDisplay().getElement());

// Error handler
guac.onerror = function(error) {
    // alert(error);
    console.log(error);
    guac.connect();
};
guac.onstatechange = function (newState) {
    console.log(newState)
}

// Connect
guac.connect();

var reconnectTimer = setInterval(function () {
    guac.connect();;
}, 1000 * 60);

// Disconnect on close
window.onunload = function() {
    guac.disconnect();
    clearInterval(reconnectTimer);
}

/* ]]> */ </script>
</body>

</html>